package com.itheima.d5_resource;

import java.io.*;

public class Test2 {
    public static void main(String[] args) {
        InputStream is = null;
        OutputStream os = null;
        try {
            System.out.println(10 / 0);
            is = new FileInputStream("D:\\resourse\\th.jpg");
            os = new FileOutputStream("C:\\data\\th2.jpg");

            byte[] bytes = new byte[1024];
            int len;
            while ((len = is.read(bytes)) != -1) {
                os.write(bytes, 0, len);
            }

            System.out.println("拷贝成功!");
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                if (os != null) os.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
            try {
                if (is != null) is.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }
}
